\(\int (c+d x) \tan ^2(a+b x) \, dx\) [256]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [B] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 14, antiderivative size = 40 \[ \int (c+d x) \tan ^2(a+b x) \, dx=-c x-\frac {d x^2}{2}+\frac {d \log (\cos (a+b x))}{b^2}+\frac {(c+d x) \tan (a+b x)}{b} \]

[Out]

-c*x-1/2*d*x^2+d*ln(cos(b*x+a))/b^2+(d*x+c)*tan(b*x+a)/b

Rubi [A] (verified)

Time = 0.04 (sec) , antiderivative size = 40, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.143, Rules used = {3801, 3556} \[ \int (c+d x) \tan ^2(a+b x) \, dx=\frac {d \log (\cos (a+b x))}{b^2}+\frac {(c+d x) \tan (a+b x)}{b}-c x-\frac {d x^2}{2} \]

[In]

Int[(c + d*x)*Tan[a + b*x]^2,x]

[Out]

-(c*x) - (d*x^2)/2 + (d*Log[Cos[a + b*x]])/b^2 + ((c + d*x)*Tan[a + b*x])/b

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3801

Int[((c_.) + (d_.)*(x_))^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[b*(c + d*x)^m*((b*Tan[e
 + f*x])^(n - 1)/(f*(n - 1))), x] + (-Dist[b*d*(m/(f*(n - 1))), Int[(c + d*x)^(m - 1)*(b*Tan[e + f*x])^(n - 1)
, x], x] - Dist[b^2, Int[(c + d*x)^m*(b*Tan[e + f*x])^(n - 2), x], x]) /; FreeQ[{b, c, d, e, f}, x] && GtQ[n,
1] && GtQ[m, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {(c+d x) \tan (a+b x)}{b}-\frac {d \int \tan (a+b x) \, dx}{b}-\int (c+d x) \, dx \\ & = -c x-\frac {d x^2}{2}+\frac {d \log (\cos (a+b x))}{b^2}+\frac {(c+d x) \tan (a+b x)}{b} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.42 (sec) , antiderivative size = 76, normalized size of antiderivative = 1.90 \[ \int (c+d x) \tan ^2(a+b x) \, dx=-\frac {c \arctan (\tan (a+b x))}{b}+\frac {d \log (\cos (a+b x))}{b^2}-\frac {d x \sec (a) (b x \cos (a)-2 \sin (a))}{2 b}+\frac {d x \sec (a) \sec (a+b x) \sin (b x)}{b}+\frac {c \tan (a+b x)}{b} \]

[In]

Integrate[(c + d*x)*Tan[a + b*x]^2,x]

[Out]

-((c*ArcTan[Tan[a + b*x]])/b) + (d*Log[Cos[a + b*x]])/b^2 - (d*x*Sec[a]*(b*x*Cos[a] - 2*Sin[a]))/(2*b) + (d*x*
Sec[a]*Sec[a + b*x]*Sin[b*x])/b + (c*Tan[a + b*x])/b

Maple [A] (verified)

Time = 1.18 (sec) , antiderivative size = 52, normalized size of antiderivative = 1.30

method result size
norman \(\frac {c \tan \left (x b +a \right )}{b}+\frac {d x \tan \left (x b +a \right )}{b}-c x -\frac {d \,x^{2}}{2}-\frac {d \ln \left (1+\tan \left (x b +a \right )^{2}\right )}{2 b^{2}}\) \(52\)
parallelrisch \(-\frac {d \,x^{2} b^{2}-2 d \tan \left (x b +a \right ) x b +2 c x \,b^{2}-2 c \tan \left (x b +a \right ) b +d \ln \left (1+\tan \left (x b +a \right )^{2}\right )}{2 b^{2}}\) \(56\)
default \(-\frac {d \,x^{2}}{2}-c x +\frac {-\frac {d a \tan \left (x b +a \right )}{b}+c \tan \left (x b +a \right )+\frac {d \left (\left (x b +a \right ) \tan \left (x b +a \right )+\ln \left (\cos \left (x b +a \right )\right )\right )}{b}}{b}\) \(63\)
risch \(-\frac {d \,x^{2}}{2}-c x -\frac {2 i d x}{b}-\frac {2 i d a}{b^{2}}+\frac {2 i \left (d x +c \right )}{b \left ({\mathrm e}^{2 i \left (x b +a \right )}+1\right )}+\frac {d \ln \left ({\mathrm e}^{2 i \left (x b +a \right )}+1\right )}{b^{2}}\) \(69\)

[In]

int((d*x+c)*tan(b*x+a)^2,x,method=_RETURNVERBOSE)

[Out]

c/b*tan(b*x+a)+d*x/b*tan(b*x+a)-c*x-1/2*d*x^2-1/2*d/b^2*ln(1+tan(b*x+a)^2)

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 53, normalized size of antiderivative = 1.32 \[ \int (c+d x) \tan ^2(a+b x) \, dx=-\frac {b^{2} d x^{2} + 2 \, b^{2} c x - d \log \left (\frac {1}{\tan \left (b x + a\right )^{2} + 1}\right ) - 2 \, {\left (b d x + b c\right )} \tan \left (b x + a\right )}{2 \, b^{2}} \]

[In]

integrate((d*x+c)*tan(b*x+a)^2,x, algorithm="fricas")

[Out]

-1/2*(b^2*d*x^2 + 2*b^2*c*x - d*log(1/(tan(b*x + a)^2 + 1)) - 2*(b*d*x + b*c)*tan(b*x + a))/b^2

Sympy [A] (verification not implemented)

Time = 0.16 (sec) , antiderivative size = 65, normalized size of antiderivative = 1.62 \[ \int (c+d x) \tan ^2(a+b x) \, dx=\begin {cases} - c x - \frac {d x^{2}}{2} + \frac {c \tan {\left (a + b x \right )}}{b} + \frac {d x \tan {\left (a + b x \right )}}{b} - \frac {d \log {\left (\tan ^{2}{\left (a + b x \right )} + 1 \right )}}{2 b^{2}} & \text {for}\: b \neq 0 \\\left (c x + \frac {d x^{2}}{2}\right ) \tan ^{2}{\left (a \right )} & \text {otherwise} \end {cases} \]

[In]

integrate((d*x+c)*tan(b*x+a)**2,x)

[Out]

Piecewise((-c*x - d*x**2/2 + c*tan(a + b*x)/b + d*x*tan(a + b*x)/b - d*log(tan(a + b*x)**2 + 1)/(2*b**2), Ne(b
, 0)), ((c*x + d*x**2/2)*tan(a)**2, True))

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 237 vs. \(2 (38) = 76\).

Time = 0.31 (sec) , antiderivative size = 237, normalized size of antiderivative = 5.92 \[ \int (c+d x) \tan ^2(a+b x) \, dx=-\frac {2 \, {\left (b x + a - \tan \left (b x + a\right )\right )} c - \frac {2 \, {\left (b x + a - \tan \left (b x + a\right )\right )} a d}{b} + \frac {{\left ({\left (b x + a\right )}^{2} \cos \left (2 \, b x + 2 \, a\right )^{2} + {\left (b x + a\right )}^{2} \sin \left (2 \, b x + 2 \, a\right )^{2} + 2 \, {\left (b x + a\right )}^{2} \cos \left (2 \, b x + 2 \, a\right ) + {\left (b x + a\right )}^{2} - {\left (\cos \left (2 \, b x + 2 \, a\right )^{2} + \sin \left (2 \, b x + 2 \, a\right )^{2} + 2 \, \cos \left (2 \, b x + 2 \, a\right ) + 1\right )} \log \left (\cos \left (2 \, b x + 2 \, a\right )^{2} + \sin \left (2 \, b x + 2 \, a\right )^{2} + 2 \, \cos \left (2 \, b x + 2 \, a\right ) + 1\right ) - 4 \, {\left (b x + a\right )} \sin \left (2 \, b x + 2 \, a\right )\right )} d}{{\left (\cos \left (2 \, b x + 2 \, a\right )^{2} + \sin \left (2 \, b x + 2 \, a\right )^{2} + 2 \, \cos \left (2 \, b x + 2 \, a\right ) + 1\right )} b}}{2 \, b} \]

[In]

integrate((d*x+c)*tan(b*x+a)^2,x, algorithm="maxima")

[Out]

-1/2*(2*(b*x + a - tan(b*x + a))*c - 2*(b*x + a - tan(b*x + a))*a*d/b + ((b*x + a)^2*cos(2*b*x + 2*a)^2 + (b*x
 + a)^2*sin(2*b*x + 2*a)^2 + 2*(b*x + a)^2*cos(2*b*x + 2*a) + (b*x + a)^2 - (cos(2*b*x + 2*a)^2 + sin(2*b*x +
2*a)^2 + 2*cos(2*b*x + 2*a) + 1)*log(cos(2*b*x + 2*a)^2 + sin(2*b*x + 2*a)^2 + 2*cos(2*b*x + 2*a) + 1) - 4*(b*
x + a)*sin(2*b*x + 2*a))*d/((cos(2*b*x + 2*a)^2 + sin(2*b*x + 2*a)^2 + 2*cos(2*b*x + 2*a) + 1)*b))/b

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 203 vs. \(2 (38) = 76\).

Time = 0.45 (sec) , antiderivative size = 203, normalized size of antiderivative = 5.08 \[ \int (c+d x) \tan ^2(a+b x) \, dx=-\frac {b^{2} d x^{2} \tan \left (b x\right ) \tan \left (a\right ) + 2 \, b^{2} c x \tan \left (b x\right ) \tan \left (a\right ) - b^{2} d x^{2} - 2 \, b^{2} c x + 2 \, b d x \tan \left (b x\right ) + 2 \, b d x \tan \left (a\right ) - d \log \left (\frac {4 \, {\left (\tan \left (b x\right )^{2} \tan \left (a\right )^{2} - 2 \, \tan \left (b x\right ) \tan \left (a\right ) + 1\right )}}{\tan \left (b x\right )^{2} \tan \left (a\right )^{2} + \tan \left (b x\right )^{2} + \tan \left (a\right )^{2} + 1}\right ) \tan \left (b x\right ) \tan \left (a\right ) + 2 \, b c \tan \left (b x\right ) + 2 \, b c \tan \left (a\right ) + d \log \left (\frac {4 \, {\left (\tan \left (b x\right )^{2} \tan \left (a\right )^{2} - 2 \, \tan \left (b x\right ) \tan \left (a\right ) + 1\right )}}{\tan \left (b x\right )^{2} \tan \left (a\right )^{2} + \tan \left (b x\right )^{2} + \tan \left (a\right )^{2} + 1}\right )}{2 \, {\left (b^{2} \tan \left (b x\right ) \tan \left (a\right ) - b^{2}\right )}} \]

[In]

integrate((d*x+c)*tan(b*x+a)^2,x, algorithm="giac")

[Out]

-1/2*(b^2*d*x^2*tan(b*x)*tan(a) + 2*b^2*c*x*tan(b*x)*tan(a) - b^2*d*x^2 - 2*b^2*c*x + 2*b*d*x*tan(b*x) + 2*b*d
*x*tan(a) - d*log(4*(tan(b*x)^2*tan(a)^2 - 2*tan(b*x)*tan(a) + 1)/(tan(b*x)^2*tan(a)^2 + tan(b*x)^2 + tan(a)^2
 + 1))*tan(b*x)*tan(a) + 2*b*c*tan(b*x) + 2*b*c*tan(a) + d*log(4*(tan(b*x)^2*tan(a)^2 - 2*tan(b*x)*tan(a) + 1)
/(tan(b*x)^2*tan(a)^2 + tan(b*x)^2 + tan(a)^2 + 1)))/(b^2*tan(b*x)*tan(a) - b^2)

Mupad [B] (verification not implemented)

Time = 25.92 (sec) , antiderivative size = 52, normalized size of antiderivative = 1.30 \[ \int (c+d x) \tan ^2(a+b x) \, dx=-c\,x-\frac {d\,x^2}{2}-\frac {\frac {d\,\ln \left ({\mathrm {tan}\left (a+b\,x\right )}^2+1\right )}{2}-b\,\left (c\,\mathrm {tan}\left (a+b\,x\right )+d\,x\,\mathrm {tan}\left (a+b\,x\right )\right )}{b^2} \]

[In]

int(tan(a + b*x)^2*(c + d*x),x)

[Out]

- c*x - (d*x^2)/2 - ((d*log(tan(a + b*x)^2 + 1))/2 - b*(c*tan(a + b*x) + d*x*tan(a + b*x)))/b^2